package com.ljl.test;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.entity.Billrecord;
import com.entity.Odo;
import com.entity.Order;
import com.entity.Orderdetail;
import com.entity.Payrecord;
import com.service.ljl.billrecordservice;
import com.service.ljl.odoservice;
import com.service.ljl.orderdetailservice;


public class odotest {
	private odoservice odoservice;
	@Before
	public void init() {
		ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
		odoservice=ac.getBean(odoservice.class);
	}
	@After
	public void tearDown() {
		odoservice=null;
	}
	
	@Test
	public void add() {
		Odo odo=new Odo();
		Order order=new Order();
		order.setOrId(3);
		odo.setOrder(order);
		odoservice.add(odo);
	}
	@Test
	public void delete() {
		odoservice.delete(74L);
	}
	
	
	@Test
	public void updatestate() {
		odoservice.updatestate(8L, new BigDecimal(2));
	}
	
	@Test
	public void find() {
		Map<Object, Object> map=odoservice.findall(10, 1);
		List<Odo> li=(List<Odo>) map.get("odos");
		for(int i=0;i<li.size();i++) {
			System.out.println(li.get(i).getInvoices().get(0).getInState());
		}
	}
	@Test
	public void addodo() {
		Map<Object, Object> map=new HashMap<>();
		List<Integer> deids=new ArrayList<>();
		deids.add(38);
		deids.add(2);
		map.put("odo", new Odo());
		map.put("orid",3);
		map.put("deids",deids);
		odoservice.addodo(map);
	}

}
